
//---------------------------------------------------------------------------
#ifndef PG2_VERTEXBUFFER_H
#define PG2_VERTEXBUFFER_H
//---------------------------------------------------------------------------
#include "pg2_api.h"
//---------------------------------------------------------------------------
#include <d3d9.h>
#include <d3dx9.h>
#include <cassert>
//---------------------------------------------------------------------------
namespace pg2
{
//---------------------------------------------------------------------------
template <class PixelFormatClass>
class PG2_API VertexBuffer
{
public:
	VertexBuffer (IDirect3DDevice9* pkDevice, unsigned int uiFVF, bool bDynamic = true);

	void bind ();
	void flush ();
	void draw (const PixelFormatClass* akVertices, D3DPRIMITIVETYPE ePrimitiveType, unsigned int uiVertexCount);
	
private:
	unsigned int m_uiVbSize;
	unsigned int m_uiFlush;
	unsigned int m_uiBase;
	unsigned int m_uiVtxToLock;
	
	unsigned int m_uiFVF;

	D3DPRIMITIVETYPE m_ePrimitiveType;
	LPDIRECT3DVERTEXBUFFER9 m_pkVertexBuffer;
	IDirect3DDevice9* m_pkDevice;
};
//---------------------------------------------------------------------------
#include "pg2_vertexBuffer.inl"
//---------------------------------------------------------------------------
} // end namespace
//---------------------------------------------------------------------------
#endif  // PG2_VERTEXBUFFER_H
//---------------------------------------------------------------------------
